<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>积分记录</title>
    <link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/font-awesome.min93e3.css?v=4.4.0"/>
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/css/jquery.dataTables.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/datapicker/datepicker3.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css">
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/plugins/chosen/chosen.css"/>
    <link rel="stylesheet" type="text/css" href="<%=path%>/hplus/css/style.min.css"/>
    <link href="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.css" rel="stylesheet">
    <style type="text/css">
	body{font-size: 14px;}
		a{color:black;padding: 0 8px;}
		a:hover{color:#1ab394;}
		a.currentNode{color:#1ab394;}
		.radio{margin-top: 0;}
		.radio-primary input[type="radio"] + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::after {background-color: #1ab394;}
		.radio-primary input[type="radio"]:checked + label::before {border-color: #1ab394;}
	</style>
</head>
<body class="gray-bg">

	
<div class="container-fluid">

		<div class="col-sm-12" style="height:80px;">
                <h4><a href="staffList.html" onclick="javascript:location.replace(this.href);event.returnValue=false;">员工列表></a><span id="liename"></span>>积分记录</h4>
        </div>
        <div class="couton" style="padding: 10px,0,0,0">
			<button type="button" class="btn btn-default btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('1')">员工概况</button>
			<button type="button" class="btn btn-info btn-lg" style="background-color: white;color: black;border:none;" onclick="messagestaff('2')">积分纪录</button>      
			<button type="button" class="btn btn-info btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('3')">邀请粉丝</button>      
			<button type="button" class="btn btn-info btn-lg" style="background-color: #F5F5F5;color: black;border:none;" onclick="messagestaff('4')">邀请会员</button>      
		</div>
	 <div class="row" style="background-color: white;">
    	<div class="col-sm-4">
        </div>
        <div class="col-sm-8 text-right">
        		<a id="export" href="javascript:void(0)">
            	<button class="btn btn-primary" type="button">导出CSV</button>
            	</a>
        </div>
    </div>
    <!--列表头  -->
    <div class="wt100" style="position:relative; overflow:hidden; height:100%">
	        <table id="myTable" class="display" cellspacing="0" width="100%">
	            <thead>
	            <tr>
	                <th>时间</th>
	                <th>描述</th>
	                <th>积分</th>
	            </tr>
	            </thead>
	            <tbody>   
	            </tbody>
	        </table>
    </div>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/datatables/1.10.16/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/datapicker/bootstrap-datepicker.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script type="text/javascript" src="<%=path%>/hplus/js/plugins/chosen/chosen.jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.17.0/jquery.validate.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/artDialog/7.0.0/dialog-plus.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="<%=path%>/hplus/js/plugins/sweetalert/sweetalert2.min.js"></script>
<script type="text/javascript" src="<%=path%>/js/dateUtils.js"></script>
<script type="text/javascript">
$.fn.dataTable.ext.errMode = 'none';
var path = "<%=path%>";
var staffId = getUrlParam("id");
var name = decodeURI(getUrlParam("name"));

    $(function () {
    	$("#liename").text(name);
        init();
    });
    
    function getUrlParam(key){
    	var reg = new RegExp("(^|&)"+ key +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if(r!=null)return  unescape(r[2]); return null;
    }	
    /*页面跳转  */
    function messagestaff(id){
    	var name = $("#liename").text();
		if(id == 1){
			window.location.href="<%=path%>/view/ui/staffdetails?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else if(id == 2){
			window.location.href="<%=path%>/view/ui/integralrecord?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else if(id == 3){
			window.location.href="<%=path%>/view/ui/invitingfans?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}else{
			window.location.href="<%=path%>/view/ui/invitingmembers?id="+staffId+"&name="+encodeURI(encodeURI(name))
		}
    }
    
    
	/* 初始化页面 */
    function init() {
        myDataTable = dataTable();
    }


    $("#export").click(function(){
		var href = path+"/staff/exportALLlist?staffId="+staffId;
		$(this).attr("href",href);
	});
  


    function func_AjaxUrl() {
          return path + "/staff/ajaxStaffIntegralrecord"; 
    }

    function func_columns() {
        var jsonArr = [
            {"data": "createTime"},
            {"data": "description"},
            {"data": "score"},
        ];
        return jsonArr;
    }

    function func_ajaxData() {
        var jsonObject = new Object();
        jsonObject.staff_id=staffId
        return jsonObject;
    }

    function dataTable() {
        return $('#myTable').DataTable({
            processing: true,
            searching: false,
            ordering:true,
            bFilter:true,
            info: true,
            autoWidth: true,
            lengthChange: false,
            language: {
                emptyTable: '没有数据表',
                info: '从第 _START_ 到第 _END_ 条数据；总共有 _TOTAL_ 条记录',
                infoEmpty: '没有数据',
                lengthMenu: '每页显示 _MENU_ 条记录',
                loadingRecords: '正在加载数据....',
                processing: '正在处理数据....',
                zeroRecords: '没有找到匹配的记录',
                paginate: {
                    first: '首页',
                    previous: '前页',
                    next: '后页',
                    last: '尾页'
                }
            },
            order: [[1, 'desc']],
            pageLength: 20,
            pagingType: 'full_numbers',
            
            columnDefs: [{
                render: function (data, type, full) {
                    var result = "";
                    if (data==null) {
                        result = "——";
                    } else {
                    	return " "+formatDateTimeYMDHMS(data);
                    }
                    return result;
                },
                targets: 0,
            }, {
                render: function (data, type, full) {
                    var result = "";
                    if (data.indexOf("null")!=-1) {
                        result = data.replace("null","游客");
                    }else if(data.endsWith("被点击")){
                    	if(full.clickNickName != null && full.clickNickName != ""){
                        	result = data.substring(0,data.length-2)+full.clickNickName+"点击";
                    	}else{
                    		result = data.substring(0,data.length-2)+"游客点击";
                    	}
                    }else{
                    	result = data;
                    }
                    return result;
                },
                targets: 1,
            }, {
                render: function (data, type, full) {
                    var result = "";
                     if (data == null) {
                         result = "——";
                     } else {
                         result = data;
                     }
                    return result;
                },
                targets: 2,
            }],
            columns: func_columns(),
            serverSide: true,
            ajax: {
                contentType: 'application/json;charset=utf-8',
                type: 'POST',
                url: func_AjaxUrl(),
                data: function (d) {
                    d.extra_search = func_ajaxData();
                    return JSON.stringify(d);
                }
            }
        });
    }

	
	
	
</script>
</html>